import Vue from 'vue'
import VueRouter from 'vue-router'
// import first from '../views/index/index.vue'
// import login from '../views/login/index.vue'

Vue.use(VueRouter)

const router = new VueRouter({
	routes:[
		{
			path:'/',
			component:()=>import('@/views/login/index.vue'),
			meta:{requiresAuth:false},
		},
		{
			path:'/index',
			component:()=>import('@/Layouts/index.vue'),
			meta:{requiresAuth:true},
			children:[
				{
					path:"",
					component:()=>import('@/views/index/index.vue')
				},
				{
					path:'/Platform_upload',
					component:()=>import('@/views/Article/index.vue')
				},
				{
					path:'/User_upload',
					component:()=>import('@/views/Article/User_upload.vue')
				},
			]
		},
		{
			path:'/Article',
			component:()=>import('@/Layouts/index.vue'),
			meta:{requiresAuth:true},
			children:[
				{
					path:"",
					component:()=>import('@/views/index/index.vue')
				},
			]
		}
	]
})

// router.beforeEach((to,from,next)=>{
// 	if(to.meta.requiresAuth){
// 		let userinfo = JSON.parse(localStorage.getItem('userinfo'))
// 		if(userinfo===null || userinfo===undefined){
// 			router.push({
// 				path:'/login'
// 			})
// 		}else{
// 			next()
// 		}
// 	}else{
// 		next()
// 	}
// })
export default router